package org.me.runaway;


public class Place {
    public static final int ID = 0;
    public static final int NAME_ID = 1;
    public static final int LAT_ID = 2;
    public static final int LNG_ID = 3;
    public static final int ADDRESS_ID = 4;
    public static final int DETAILS_ID = 5;
    public static final int PRICE_ID = 6;
    public static final int SCHEDULE_ID = 7;
    public static final int CONTACT1_ID = 8;
    public static final int CONTACT2_ID = 9;
    public static final int FAVORITE_ID = 10;
    public static final int RATE_ID = 11;
    public static final int TYPE_ID = 12;
    public static final int IMAGE_ID = 13;
    public static final int UPDATED_ID = 14;
    public static final int VOTED_ID = 15;

    public static final String KEY_ROWID = "_id";
    public static final String KEY_NAME = "name";
    public static final String KEY_LAT = "latitude";
    public static final String KEY_LNG = "longitude";
    public static final String KEY_ADDRESS = "address";
    public static final String KEY_DETAILS = "details";
    public static final String KEY_PRICE = "price";
    public static final String KEY_SCHEDULE = "schedule";
    public static final String KEY_CONTACT1 = "contact1";
    public static final String KEY_CONTACT2 = "contact2";
    public static final String KEY_FAVORITE = "favorite";
    public static final String KEY_RATE = "rate";
    public static final String KEY_TYPE = "type";
    public static final String KEY_IMAGE = "image";
    public static final String KEY_UPDATED = "updated";
    public static final String KEY_VOTED = "voted";


    public static final String[] specification = new String[] { Place.KEY_ROWID,
        Place.KEY_NAME, Place.KEY_LAT, Place.KEY_LNG, Place.KEY_ADDRESS,Place.KEY_DETAILS,
        Place.KEY_PRICE, Place.KEY_SCHEDULE, Place.KEY_CONTACT1, Place.KEY_CONTACT1,
        Place.KEY_FAVORITE, Place.KEY_RATE, Place.KEY_TYPE, Place.KEY_IMAGE, Place.KEY_UPDATED,
        Place.KEY_VOTED};

    private long id;
    private String name;
    private double lat;
    private double lng;
    private String address;
    private String details;
    private int price;
    private String schedule;
    private int contact1;
    private int contact2;
    private boolean favorite;
    private String rate;
    private String type;
    private String image;
    private boolean updated;
    private boolean voted;

    public Place() {
        this.name="name";
        this.lat=0.0;
        this.lng=0.0;
        this.address="address";
        this.details="details";
        this.price=0;
        this.schedule="00h00-00h00/00h00-00h00";
        this.contact1 = 000000000;
        this.contact2 = 000000000;
        this.favorite=false;
        this.rate="0/0";
        this.type="type";
        this.image="image";
        this.updated=true;
        this.voted=false;
    }

    public Place(String name, double lat, double lng, String address,
            String details, int price, String schedule, int contact1, int contact2,
            boolean favorite, String rate, String type, String image, boolean updated, boolean voted) {
        this.name=name;
        this.lat=lat;
        this.lng=lng;
        this.address=address;
        this.details=details;
        this.price=price;
        this.schedule=schedule;
        this.contact1 = contact1;
        this.contact2 = contact2;
        this.favorite=favorite;
        this.rate=rate;
        this.type=type;
        this.image=image;
        this.updated=updated;
        this.voted=voted;
    }

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the lat
     */
    public double getLatitude() {
        return lat;
    }

    /**
     * @param lat the lat to set
     */
    public void setLatitude(double lat) {
        this.lat = lat;
    }

    /**
     * @return the lng
     */
    public double getLongitude() {
        return lng;
    }

    /**
     * @param lng the lng to set
     */
    public void setLongitude(double lng) {
        this.lng = lng;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @return the details
     */
    public String getDetails() {
        return details;
    }

    /**
     * @param details the details to set
     */
    public void setDetails(String details) {
        this.details = details;
    }

    /**
     * @return the price
     */
    public int getPrice() {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(int price) {
        this.price = price;
    }

    /**
     * @return the schedule
     */
    public String getSchedule() {
        return schedule;
    }

    /**
     * @param schedule the schedule to set
     */
    public void setSchedule(String schedule) {
        this.schedule = schedule;
    }

    /**
     * @return the contact1
     */
    public int getContact1() {
        return contact1;
    }

    /**
     * @param contact1 the contact1 to set
     */
    public void setContact1(int contact1) {
        this.contact1 = contact1;
    }

    /**
     * @return the contact2
     */
    public int getContact2() {
        return contact2;
    }

    /**
     * @param contact2 the contact2 to set
     */
    public void setContact2(int contact2) {
        this.contact2 = contact2;
    }

    /**
     * @return the favorite
     */
    public boolean isFavorite() {
        return favorite;
    }

    /**
     * @param favorite the favorite to set
     */
    public void setFavorite(boolean favorite) {
        this.favorite = favorite;
    }

    /**
     * @return the rate
     */
    public String getRate() {
        return rate;
    }

    /**
     * @param rate the rate to set
     */
    public void setRate(String rate) {
        this.rate = rate;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * @return the image
     */
    public String getImage() {
        return image;
    }

    /**
     * @param image the image to set
     */
    public void setImage(String image) {
        this.image = image;
    }

    /**
     * @return the updated
     */
    public boolean isUpdated() {
        return updated;
    }

    /**
     * @param updated the updated to set
     */
    public void setUpdated(boolean updated) {
        this.updated = updated;
    }

    /**
     * @return the voted
     */
    public boolean isVoted() {
        return voted;
    }

    /**
     * @param voted the voted to set
     */
    public void setVoted(boolean voted) {
        this.voted = voted;
    }

    public static Place parsePlace(String str){
        Place p = new Place();
        String[] s = str.split("_");

        p.setName(s[0]);
        p.setLatitude(Double.parseDouble(s[1]));
        p.setLongitude(Double.parseDouble(s[2]));
        p.setAddress(s[3]);
        p.setDetails(s[4]);
        p.setPrice(Integer.parseInt(s[5]));
        p.setSchedule(s[6]);
        p.setContact1(Integer.parseInt(s[7]));
        p.setContact2(Integer.parseInt(s[8]));
        p.setFavorite(Boolean.parseBoolean(s[9]));
        p.setRate(s[10]);
        p.setType(s[11]);
        p.setImage(s[12]);
        p.setUpdated(Boolean.parseBoolean(s[13]));
        p.setVoted(false);

        return p;
    }
}
